import show_toast from '@dfeidao/atom-wxapp/api/interaction/show-toast';
import stop_pull_down from '@dfeidao/atom-wxapp/api/interaction/stop-pull-down-refresh';
import { IFeidaoAiWeappPage } from '@dfeidao/atom-wxapp/interfaces';
import get_local from '@dfeidao/atom-wxapp/local/get';
import set_local from '@dfeidao/atom-wxapp/local/set';
import nodejs from '@dfeidao/atom-wxapp/msg/nodejs';
import render from '@dfeidao/atom-wxapp/render/render';

export default async function a004(fd: IFeidaoAiWeappPage) {
	const search = get_local(fd, 'search');
	const data = get_local<[]>(fd, 'data');
	const page_no = get_local<number>(fd, 'page_no');
	set_local(fd, 'page_no', page_no + 1);

	try {
		// app-fd_staff_findName
		const data1 = await nodejs<[]>('app-equip_list/s002', {
			systemid: '6641',
			sort: {
				retailer_store_no: 1
			},
			page_no: page_no + 1,
			page_size: 1,
			name: search

		});
		console.log(data1);
		if (data1.length > 0) {
			render(fd, { data: data1.concat(data) });
			stop_pull_down();
		} else {
			show_toast('没有更多数据了', 'none');
			stop_pull_down();
		}
		set_local(fd, 'data', data);
	} catch (error) {
		console.warn(error);
	}
}
